package com.flyco.modules.stm.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableName;

import com.flyco.common.system.base.entity.BaseEntity;
import com.flyco.modules.stm.enmu.DistributorScopeTypeEnum;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author jeffery
 * @date 2021-08-05 10:56
 */
@Data
@TableName("t_dist_distributor")
public class DistributorEntity {



    private Integer type;

    private Long distributorTypeId;

    private Long memberId;

    private String realName;

    private String mobile;

    private String licenseImage;

    private String inviteCode;

    private Long inviteMemberId;

    private Integer inviteMemberType;

    private BigDecimal agencyRewardRate;

    private BigDecimal inviterAgencyReward;

    private BigDecimal firstPayAmount;

    private String agreementFile;

    private String purchaseListFile;

    private Integer status;

    private Date beginTime;

    private Date endTime;

    private Date nextEvaluationTime;

    private Date applyTime;

    private Integer auditStatus;

    private Date auditTime;

    private Date revokeTime;

    private BigDecimal priceDiscount;

    private Integer scopeType;

    private String scope;

    private String achievementRewardKey;

    private Long districtId;

    private Integer defaultTeamConfigFlag;

    private Integer defaultSelfConfigFlag;

    private Long teamAchievementGradeId;

    private Long selfAchievementGradeId;

    private BigDecimal teamRewardBaseDiscount;

    private Integer accountNum;

    private Integer remainNum;

    private Integer receivedNum;

    private String payVoucher;

    public Boolean canSalesGoodsBrandCates(List<Integer> goodsCateList) {
        if (CollectionUtils.isEmpty(goodsCateList)) {
            return Boolean.FALSE;
        }
        if (DistributorScopeTypeEnum.ALL.getCode().equals(this.scopeType)) {
            return Boolean.TRUE;
        } else {
            if (StringUtils.isNotEmpty(this.scope)) {
                List<Integer> scopeList = JSON.parseArray(this.scope, Integer.class);
                if (CollectionUtils.isNotEmpty(scopeList)) {
                    for (Integer scope : scopeList) {
                        if (goodsCateList.contains(scope)) {
                            return Boolean.TRUE;
                        }
                    }
                }
            }
        }
        return Boolean.FALSE;
    }
}
